package com.example.demo.controller;

import com.example.demo.annotation.LimitRequest;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/api/seckill")
@RestController
public class SeckillController {

    /**
     * 秒杀商品
     * @param id    商品id
     */
    @LimitRequest(seckillId = 1)
    @PostMapping("/{id}")
    public void seckill(@PathVariable("id") Long id){
        // 1、切面判断了线程是否能访问...

        // 2、秒杀
        // ...
        log.debug("秒杀完成");

        // 3、...
    }
}
